import request from 'umi-request';
import { useState, useEffect } from 'react';

const useWeather = () => {
  const [temp, set_temp] = useState<string>('');
  useEffect(() => {
    request
      .get(
        'http://api.k780.com/?app=weather.realtime&weaId=94&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
      )
      .then((response) => {
        set_temp(response.result?.realTime?.wtTemp);
      });
  }, []);
  return temp;
};

export default useWeather;
